package Controllers;

import Exceptions.DaoException;
import Interfaces.IStoreEntry_Dao;
import Models.StoreEntry;
import javax.swing.JOptionPane;

public class StoreEntry_Controller {

    private IStoreEntry_Dao x;

    public StoreEntry_Controller(IStoreEntry_Dao x) {
        this.x = x;
    }

    public StoreEntry_Controller() {

    }

    public StoreEntry Validate3(String StoreName, String Address, String City, String StorePhone, String Floors, String Seats, String Parking, String ParkingSpots, String DaysOpen) throws IllegalArgumentException, DaoException {

        if (StoreName.isEmpty() || Address.isEmpty() || StorePhone.isEmpty() || Floors.isEmpty() || City.isEmpty() || ParkingSpots.isEmpty() || DaysOpen.isEmpty() || Parking.isEmpty() || Seats.isEmpty()) {
            JOptionPane.showMessageDialog(null, "There is an empty field.");
        } else if (StorePhone.length() > 10 || StorePhone.length() < 10) {
            JOptionPane.showMessageDialog(null, "Wrong StorePhone");
        } else if (StorePhone.matches("[0-9]+") == false) {
            JOptionPane.showMessageDialog(null, "StorePhone must contain digits ONLY");
        } else if (Floors.matches("[0-9]+") == false) {
            JOptionPane.showMessageDialog(null, "Floors must contain digits ONLY");
        } else if (Seats.length() < 0) {
            JOptionPane.showMessageDialog(null, "Need to have at least 1 Seat");
        } else if (Seats.matches("[0-9]+") == false) {
            JOptionPane.showMessageDialog(null, "Seats you entered is non-digit, try again");
        } else if (ParkingSpots.matches("[0-9]+") == false) {
            JOptionPane.showMessageDialog(null, "ParkingSpots you entered is non-digit, try again");
        } else {
            JOptionPane.showMessageDialog(null, "SignUp Success");
        }
        try {
            return x.ValidateStoreEntry(StoreName, Address, City, StorePhone, Floors, Seats, Parking, ParkingSpots, DaysOpen);
        } catch (DaoException e) {
            throw e;
        }

    }
}
